package com.example.wj.service;

import com.example.wj.dao.UserDao;
import com.example.wj.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    UserDao userDao;

    public User getUser(String name,String password){
        return userDao.getUserByUsernameAndPassword(name, password);
    }
    public User seachUser(String name){
        return userDao.findUserByUsername(name);
    }
    public int save(User user) {
        User save = userDao.save(user);
        if (save != null) {
            return 1;
        } else {
            return 0;
        }

    }
    public  User findUserById(Integer id){
        return userDao.findUserById(id);
    }
    public  void delete(String username){
        userDao.deleteByUsername(username);
    }
    public List<User> findAll(){
        return userDao.findAll();
    }
}
